home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Practical Algorithms for Image Analysis
/
Practical Algorithms for Image Analysis.iso
/
CH_6.3
/
XSGT
/
ANAL_GT.C
next >
Wrap
C/C++ Source or Header
|
1999-09-11
|
3KB
|
129 lines
/*
* anal_gt.c
*
* Practical Algorithms for Image Analysis
*
* Copyright (c) 1997, 1998, 1999 MLMSoftwareGroup, LLC
*/
/*
* ANAL(yze)_G(eometry and) T(opology)
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <stdarg.h>
#include <math.h>
#include <string.h>
#include "vora.h"
/* globals */
extern int CHECK_EDGE;
/*
* extract, from struct vSite array, vPoly areas and domain areas,
* both normalized to their respective mean values, for later processing
*/
int
a_vs_vPa (struct Pix *dpa, int ns, struct vSite *vsa, double *a_bar, double *va_bar)
{
int is, nma;
double ma, mva;
struct vSite *vS;
nma = 0;
ma = 0.0;
mva = 0.0;
for (is = 0; is < ns; is++) {
if (((vS = (vsa + is))->eFlag == UnSet) &&
(vS->aoiFlag == UnSet)) {
mva += (dpa + is)->x = (float) (vsa + is)->v_area;
ma += (dpa + is)->y = (float) (vsa + is)->area;
nma++;
}
}
*va_bar = (mva /= (double) nma);
*a_bar = (ma /= (double) nma);
for (is = 0; is < ns; is++) {
if (((vS = (vsa + is))->eFlag == UnSet) &&
(vS->aoiFlag == UnSet)) {
(dpa + is)->x /= (float) mva;
(dpa + is)->y /= (float) ma;
}
else {
(dpa + is)->x = (float) -1.0;
(dpa + is)->y = (float) -1.0;
}
}
return (nma);
}
/*
* joint probability distribution, p(n, A)
* construct joint probability distribution, p(n, A), of site
* coordination, n, and bubble domain area, A
*/
double
p_of_nA (int *ndn, unsigned int *a_n[], int ns, struct vSite *vsa)
{
int is, cnn;
int nma;
double ma;
struct vSite *vS;
nma = 0;
ma = 0.0;
for (is = 0; is < ns; is++) {
if (((vS = (vsa + is))->eFlag == UnSet) &&
(vS->aoiFlag == UnSet)) {
cnn = (vsa + is)->nnn;
*(a_n[cnn] + ndn[cnn]) = (vsa + is)->area;
ndn[cnn]++;
ma += (vsa + is)->area;
nma++;
}
}
ma /= (double) nma;
return (ma);
}
/*
* evaluate distance of closest approach between NN pairs of domains
*
* eFlag and aoiFlag are of type Boolean
*/
int
eval_sij (float *bs[], int ns, struct vSite *vsa)
{
int ibs;
int is, inn;
double r_i, r_j;
struct vSite *vS;
printf ("\n");
ibs = 0;
for (is = 0; is < ns; is++) {
if (((vS = (vsa + is))->eFlag == UnSet) &&
(vS->aoiFlag == UnSet)) {
r_i = sqrt ((double) (vS->area) / PI);
for (inn = 0; inn < vS->nnn; inn++) {
r_j = sqrt ((double) (vsa + (vS->nnsi[inn]))->area / PI);
*(bs[is] + inn) = vS->nnd[inn] - (float) (r_i + r_j);
ibs++;
}
}
else {
printf ("WARNING: Site %d out of bounds\n", vS->sitenbr);
}
}
return (ibs);
}